<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>

	<head>
		<base href="<%=basePath%>">
		<title>积分</title>
		<link rel="stylesheet" href="styles/css/bootstrap.min.css" />
		<script type="text/javascript" src="scripts/common/jquery-3.2.1.min.js"></script>
		<script type="text/javascript" src="scripts/common/bootstrap.min.js"></script>
		<script type="text/javascript" src="https://g.alicdn.com/dingding/dingtalk-pc-api/2.7.0/index.js"></script>
		<script type="text/javascript">
			var deviceInfo = DingTalkPC.ua;
			if(deviceInfo.isWeb) {
				//				window.location.href = "jsp/common/no_auth.html";
			} else {
				var _config = <%=request.getAttribute("config")%>;
				DingTalkPC.config({
					agentId: _config.agentid,
					corpId: _config.corpId,
					timeStamp: _config.timeStamp,
					nonceStr: _config.nonceStr,
					signature: _config.signature,
					jsApiList: ['runtime.info', 'biz.user.get']
				});

				DingTalkPC.ready(function(res) {
					DingTalkPC.biz.user.get({
						onSuccess: function(info) {
							var inf = {};
							inf.nickname = info.nickname;
							inf.isManager = info.isManager;
							inf.device = "pc";
							JSON.stringify(inf);

							var name = encodeURI(info.nickName);
							var isManager = info.isManager;
							var device = "pc"; //标志电脑端
							name = encodeURI(name); //一次编码
							
							var app = "${app}";
							console.log(app);
							if(app == "pm") {
								window.location.href="index?name="+name;
							}else{
								window.location.href = "userAction?name =" + name + "&isManager=" + isManager + "&device=" + device;
							}
							
						}

					});
				});
				DingTalkPC.error(function(error) {
					//config信息验证失败会执行error函数，
					//如签名过期导致验证失败，具体错误信息可以打开调试窗口的 console查看，
					//也可以在返回的res参数中查看。
					console.log(JSON.stringify(error));
				});
			}
		</script>
	</head>

	<body>
		<div class="container-fluid center-block">
			<img src="styles/images/bg_loading.gif" class="img-responsive center-block" />
		</div>
	</body>

</html>